import 'package:flutter/material.dart';

import '../config/config_index.dart';
import '../commpontents/common_place_holder_widget.dart';

abstract class CommonLessV extends StatelessWidget
    with HzyScaffolMixin, HzyAppBarMixin, HzyBodyMixin, HzyAbsAttribute {
  final CommonPlaceHoldType? placeHoldType;
  final String? placeMsg;
  final bool isShowLoading = false;
  CommonLessV({
    super.key,
    this.placeMsg,
    this.placeHoldType,
  });

  @override
  Widget build(BuildContext context) {
    return createBuild(context: context);
  }

  @override
  Widget createBuild({required BuildContext context}) {
    return createScaffolWidget(context: context);
  }

  /// 点击返回按钮
  @override
  configleadingCallbak({BuildContext? context}) {
    Navigator.pop(context!);
  }

  /// 创建空数据界面
  @override
  Widget? createEmptyWidget() {
    return CommonPlaceHoldPage(
      placeHoldType: placeHoldType ?? CommonPlaceHoldType.nothing,
      msg: placeMsg,
      ontap: () {
        tapPlaceHoldWidgetMethod(
          placeHoldType: placeHoldType ?? CommonPlaceHoldType.nothing,
        );
      },
    );
  }

  /// =============== 重写方法 =============== ///

  /// 是否使用脚手架
  @override
  bool configIsNeedScaffol() {
    return isNeedScaffol;
  }

  /// 是否使用安全区域
  @override
  bool configIsNeedSafeArea() {
    return isNeedScaffol;
  }

  /// 配置脚手架背景颜色
  @override
  Color? configScallBackgroundColor() {
    return PageNormalConfig().scallBackgroudColor;
  }

  ///是否形变
  @override
  bool? configResizeToAvoidBottomInset() {
    return resizeToAvoidBottomInset;
  }

  /// 是否关闭顶部安全区域
  @override
  bool configSafeAreaTop() {
    return safeAreaTop;
  }

  /// 是否关闭底部安全区域
  @override
  bool configSafeAreaBottom() {
    return safeAreaBottom;
  }

  /// 是否显示加载动画
  @override
  bool configIsshowLoading() {
    return isShowLoading;
  }

  @override
  bool configIsShowAppBar() {
    return isShowAppBar;
  }

  /// 配置导航栏标题
  @override
  String? createAppBarTitleStr() {
    return appBarTitle;
  }

  /// 配置导航栏背景颜色
  @override
  Color? createAppBarNavBackColor() {
    return PageNormalConfig().navBackgroundColor;
  }

  /// =============== 网络事件 =============== ///

  /// =============== 触发事件 =============== ///
  ///
  /// 点击缺省页触发事件
  tapPlaceHoldWidgetMethod({
    required CommonPlaceHoldType placeHoldType,
  }) {}
}
